/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.zapateriaLes.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.zapateriaLes.modelo.Usuarios;

/**
 *
 * @author lesly
 */
@Stateless
public class UsuariosDao extends AbstractDao<Usuarios> implements UsuariosDaoLocal {
    @PersistenceContext(unitName = "DBZapateria-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UsuariosDao() {
        super(Usuarios.class);
    }
    

   // @Override
    public boolean findDuplicity(Usuarios user) {
       Query q=em.createNamedQuery("Usuarios.findByDuplicity");
       q.setParameter("nombre", user.getNombre());
       q.setParameter("apellidoMaterno", user.getApellidoMaterno());
       q.setParameter("apellidoPaterno", user.getApellidoPaterno());
       return !q.getResultList().isEmpty();
    }
    
}
